<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
  <button style="display: inline-block;height: 50px;width: 100px" id="btn">点我呀</button>
  <div class="showTime"></div>
  <div style="height: 2000px;width: 400px;background-color: pink" id="box">
    
  </div>
  <div class="one"></div>
</body>
</html>
<script src="commonJs.js"></script>
<script>
  var b = document.querySelector(".one")
  var showTime = document.querySelector(".showTime")
  var btn  = document.querySelector("#btn")
  console.log(YK.add(10, 11));
  console.log(YK.del(10, 11));
  
  var txt = "Hello world!";
  console.log(txt.anchor("yk"));
  b.innerHTML=txt.anchor("yk"); // <a name="yk">Hello world!</a> 生成一个这样的锚点
  btn.addEventListener("click",function () {
    location.href="#yk"
  })
  
  var obj = [1,2,3]
  console.log(String(obj));
  console.log(obj.join("-"));
  var a= new String("abc");
  console.log(a[0]);
  console.log(typeof(a));
  
  
  
  let objOne = {"a":[1,2,3],"b":[3,4,5]};
  console.log(JSON.stringify(objOne)); // " {"a":[1,2,3],"b":[3,4,5]}"
  console.log(Object.values(objOne)); // [[1,2,3],[3,4,5]]  返回的是数组，数组的内容和value的值一致
  console.log(Object.keys(objOne)); // ["a","b"]
  console.log(Object.values(objOne).length==0?true:false); //false
  
  let objTwo={};
  console.log(JSON.stringify(objTwo)); // "{}"
  console.log(Object.values(objTwo).length==0?true:false); //true
  console.log(Object.values(objTwo)); // []  返回的是数组，数组的内容和value的值一致
  console.log(Object.keys(objTwo)); // []
  
  console.log(JSON.parse("{\"a\":[1,2,3],\"b\":[3,4,5]}")); // {"a":[1,2,3],"b":[3,4,5]};
  
  function sortNumber(a,b){
    return a-b;
  }
  var arr1 = [1,4,2,14,23,78,33,22,11];
  // sort的方法默认的是按照字符编码的顺序进行排序 ，也可接收一个函数，按其他的方式进行比较
  console.log(arr1.sort(sortNumber)); // [1, 2, 4, 11, 14, 22, 23, 33, 78]
  
  var obj1 = {"b":[1,23],"a":[]};
  var obj2 = obj1.a?true:false;
  console.log(obj2);

  
  setInterval(()=>{
    showTime.innerHTML=YK.time("2017-11-17 12:00");
  },500)
  
  
</script>